package com.my.blog.website.service.impl;

import com.github.pagehelper.PageInfo;
import com.my.blog.website.constant.WebConst;
import com.my.blog.website.dao.HolidayMapper;
import com.my.blog.website.model.Vo.ContentVo;
import com.my.blog.website.model.Vo.HolidayVo;
import com.my.blog.website.model.Vo.OptionVo;
import com.my.blog.website.service.IHolidayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class HolidayServiceImpl implements IHolidayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(HolidayServiceImpl.class);

    @Resource
    HolidayMapper holidayMapper;
    @Override
    public void saveHoliday(HolidayVo holiday) {
        System.out.println("进入SaveHoliday----------------------------");
        if (null != holiday) {
            System.out.println("进入SaveHoliday----if---------------------------");
         insertHoliday(holiday);
        }


    }
    @Transactional
    public void insertHoliday(HolidayVo holidayVo) {
        //LOGGER.debug("Enter insertOption method:name={},value={}", name, value);
      System.out.println("进入插入语句");
       holidayMapper.insertHoliday(holidayVo);
       System.out.println(System.out.printf("成功插入条数据"));
        LOGGER.debug("Exit insertOption method.");
    }
    @Override
    @Transactional
    public List<HolidayVo> searchHolidayVo(){
        return  holidayMapper.searchHolidayVo();
    }
    @Override
    @Transactional
    public HolidayVo searchHolidayVoById(String id1){
       int id= Integer.parseInt(id1);
       return holidayMapper.searchHolidayVoById(id);
    }
    @Override
    @Transactional
    public int updateHolidayByid(HolidayVo h){
        return holidayMapper.updateHolidayByid(h);

    }
    @Override
    @Transactional
    public String deleteByCid(int id){
      //  ContentVo contents = this.getContents(cid + "");

        if (id!=0) {
            holidayMapper.deleteByCid(id);
            //relationshipService.deleteById(cid, null);
            return WebConst.SUCCESS_RESULT;
        }
        return "数据为空";
    }

}
